package com.zhuiyun.pm.sys.stage.controller;

import com.zhuiyun.pm.page.PageRequest;
import com.zhuiyun.pm.page.PageResult;
import com.zhuiyun.pm.result.CommonResult;
import com.zhuiyun.pm.sys.stage.entity.ClientGoodsEarnestMoneyEntity;
import com.zhuiyun.pm.sys.stage.service.StageService;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * @descriptions: StageController
 * @author: zq
 * @date: 2023/3/14 15:03
 */
@RestController
@CrossOrigin
@RequestMapping("/stage")
public class StageController {
    @Resource
    StageService stageService;

    /**
     * @descriptions 查询竞品信息
     * @author zq
     * @date 2023/3/14 15:09
     * @param id
     * @return com.zhuiyun.pm.result.CommonResult
     */
    @GetMapping("/getCompetitorInfo")
    public CommonResult getCompetitorInfo(Integer id) {
        if (id != null && id != 0){
            Map stageInfo = stageService.getCompetitorInfo(id);
            return CommonResult.ok(stageInfo);
        } else {
            return CommonResult.error("id为空");
        }
    }

    /**
     * @descriptions 查询竞品报名人数
     * @author zq
     * @date 2023/3/14 16:51
     * @param goodsId
     * @return com.zhuiyun.pm.result.CommonResult
     */
    @GetMapping("/getEnrollNum")
    public CommonResult getEnrollNum(Integer goodsId){
        if (goodsId != null && goodsId != 0){
            Map enrollNum = stageService.getEnrollNum(goodsId);
            return CommonResult.ok(enrollNum);
        } else {
            return CommonResult.error("goodsId为空");
        }
    }
    
    /**
     * @descriptions 查询未缴纳保证金人数
     * @author zq
     * @date 2023/3/14 17:03
     * @param goodsId 
     * @return com.zhuiyun.pm.result.CommonResult
     */
    @GetMapping("/getUnpaidNum")
    public CommonResult getUnpaidNum(Integer goodsId){
        if (goodsId != null && goodsId != 0){
            Map enrollNum = stageService.getUnpaidNum(goodsId);
            return CommonResult.ok(enrollNum);
        } else {
            return CommonResult.error("goodsId为空");
        }
    }

    /**
     * @descriptions 查询缴纳保证金人数
     * @author zq
     * @date 2023/3/14 17:05
     * @param goodsId
     * @return com.zhuiyun.pm.result.CommonResult
     */
    @GetMapping("/getPayNum")
    public CommonResult getPayNum(Integer goodsId){
        if (goodsId != null && goodsId != 0){
            Map enrollNum = stageService.getPayNum(goodsId);
            return CommonResult.ok(enrollNum);
        } else {
            return CommonResult.error("goodsId为空");
        }
    }

    /**
     * @descriptions 查询所以报名人信息
     * @author zq
     * @date 2023/3/14 18:13
     * @param goodsId
     * @param pageRequest
     * @return com.zhuiyun.pm.result.CommonResult
     */
    @GetMapping("/getBondInfo")
    public CommonResult getBondInfo(Integer goodsId, PageRequest pageRequest){
        if (goodsId != null && goodsId != 0){
            PageResult pageResult = stageService.getBondInfo(goodsId, pageRequest);
            return CommonResult.ok(pageResult);
        } else {
            return CommonResult.error("goodsId为空");
        }
    }
}
